import 'package:dio/dio.dart';
import '../dio_service.dart';

/// 用户相关API端点
class UserEndpoints {
  static const String LOGIN = '/user/account/login';
  static const String REGISTER = '/user/account/register';
  static const String LOGOUT = '/user/account/logout';
  static const String EMAIL_CODE = '/user/account/email_code';
  static const String LOGIN_BY_EMAIL = '/user/account/login_by_email';
}

/// 用户API服务
class UAAService {
  /// 用户登录
  static Future<Response> login({
    required String username,
    required String password,
  }) async {
    return await DioService().post(
      UserEndpoints.LOGIN,
      data: {
        'username': username,
        'password': password,
      },
    );
  }

  static Future<Response> getEmailCode({
    required String email,
  }) async {
    return await DioService().post(
      UserEndpoints.EMAIL_CODE,
      data: {
        'email': email,
      },
    );
  }


  static Future<Response> loginByEmail({
    required String email,
    required String code,
  }) async {
    return await DioService().post(
      UserEndpoints.LOGIN_BY_EMAIL,
      data: {
        'email': email,
        'code': code,
      },
    );
  }

  /// 用户注册
  static Future<Response> register({
    required String username,
    required String password,
    required String email,
  }) async {
    return await DioService().post(
      UserEndpoints.REGISTER,
      data: {
        'username': username,
        'password': password,
        'email': email,
      },
    );
  }

}